﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http.Filters;
using XinHeWechat.Common;
using XinHeWechat.Model;

namespace XinHeWechat.Api.Filter
{
    public class WebApiErrorAttribute : ExceptionFilterAttribute
    {
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            LogHelper.WriteWebApiLog(actionExecutedContext.Exception);

            actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.OK, (new BaseResponse<string> { msg = actionExecutedContext.Exception.Message }));
        }
    }
}